﻿using System.Collections.Generic;
using System.Linq;
using Shared.Service.DataScopes;

namespace Shared.Service.DataScopeParsers
{

    public abstract class BaseDataScopeParser : IDataScopeParser
    {
        public IEnumerable<BaseDataScope> DataScopes { get; private set; } = new List<BaseDataScope>();

        public bool Enable { get; private set; }

        /// <summary>
        /// 是否要返回空数据
        /// </summary>
        public bool IsNull => Enable && (!DataScopes.Any() || DataScopes.HasDataScope(DataScopeType.Null));


        public void LoadDataScopes(IEnumerable<BaseDataScope> dataScopes)
        {
            DataScopes = dataScopes;
            Enable = true;
        }
    }
}
